package com.crm.customers.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.customers.dao.ContractMoneylogDao;
import com.crm.customers.model.ContractMoneylog;

@Repository("contractMoneylogDao")
public class ContractMoneylogDaoImpl extends BaseDao implements ContractMoneylogDao {
	
	private static final String MAPPER_NAMESPACE = "ContractMoneylogMapper.";

	@Override
	public int deleteByPrimaryKey(Long id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(ContractMoneylog record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public ContractMoneylog insertSelective(ContractMoneylog record) {
		insert(MAPPER_NAMESPACE+"insertSelective", record);
		return record;
	}

	@Override
	public ContractMoneylog selectByPrimaryKey(ContractMoneylog record) {
		return  selectOne(MAPPER_NAMESPACE+"selectByParam", record);
	}

	@Override
	public int updateByPrimaryKeySelective(ContractMoneylog record) {
		return update(MAPPER_NAMESPACE+"updateByPrimaryKeySelective", record);
	}

  
	@Override
	public List<ContractMoneylog> selectListByParam(ContractMoneylog record) {
		List<ContractMoneylog> list = selectList(MAPPER_NAMESPACE+"selectByParam", record);
		if (list!=null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"selectByParamCount", record));
		}
		return list;
	}

	@Override
	public ContractMoneylog selectById(Long id) {
		
		return   selectOne(MAPPER_NAMESPACE+"selectById", id);
	}

	@Override
	public List<ContractMoneylog> selectByContract(ContractMoneylog record) {
		 List<ContractMoneylog> list = selectList(MAPPER_NAMESPACE+"selectByContract", record);
		return  list;
	}

	@Override
	public int selectLogCountByParams(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"selectLogCountByParams", cml);
	}

	@Override
	public int selectTotalMoneyByParams(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"selectTotalMoneyByParamCount", cml);
	}

	@Override
	public List<ContractMoneylog> selectBnakName(ContractMoneylog cml) {
		return selectList(MAPPER_NAMESPACE+"selectBnakName", cml);
	}

	@Override
	public int selectCountFromLog(Long id) {
		return selectOne(MAPPER_NAMESPACE+"selectCountFromLog", id);
	}

	@Override
	public int updateContractid(ContractMoneylog cml) {
		return update(MAPPER_NAMESPACE+"updateContractid", cml);
	}

	@Override
	public int selectskcount(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"selectskcount", cml);
	}

	@Override
	public List<ContractMoneylog> getDKlistByParams(ContractMoneylog cml) {
		List<ContractMoneylog> list = selectList(MAPPER_NAMESPACE+"getDKlistByParams", cml);
		if (list != null && list.size() > 0 ) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getDKlistCountByParams", cml));
		}
		return list;
	}
	
	@Override
	public int getcmlcountbytype(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"getcmlcountbytype", cml);
	}

	@Override
	public Integer getcmlcountbycreatedate(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"selectcmlcountbycreatedate", cml);
	}

	@Override
	public Integer getAllApprovedMoney(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"getAllApprovedMoney", cml);
	}

	@Override
	public List<ContractMoneylog> getAllApproveAdvanceList(ContractMoneylog cml) {
		return selectList(MAPPER_NAMESPACE+"getAllApproveAdvanceList", cml);
	}

	@Override
	public Integer getAllApprovedAdvanceMoney(ContractMoneylog cml) {
		return selectOne(MAPPER_NAMESPACE+"getAllApprovedAdvanceMoney", cml);
	}

	@Override
	public int addAdvanceMoneyLog(ContractMoneylog cml) {
		return update(MAPPER_NAMESPACE+"addAdvanceMoneyLog", cml);
	}

	@Override
	public String getLastBackMoneyTime(Long contractid) {
		return selectOne(MAPPER_NAMESPACE+"getLastBackMoneyTime", contractid);
	}

	@Override
	public int selectapproveskcount(Long id) {
		return selectOne(MAPPER_NAMESPACE+"selectapproveskcount", id);
	}

}
